const Model = require('../Model');

class User extends Model{
    append = [
        'rank_name'
    ];

    autoWriteTimestamp = true;

    createTime = 'createtime';

    deleteTime = 'deletetime';

    hidden = [
        'password',
        'salt',
        'rankid'
    ];


    constructor(){
        super('file_user');
    }

    files(){
        this.belongsTo1('files_rank','rankid','id');
        // console.log('联表');
    }

    getRankNameAttr(data,value){
        const rankid = data.rankid ?? null;
        var rankname = ''
        switch(rankid){
            case 1 : 
                rankname = '超级管理员'
                break;
            case 2 :
                rankname = '管理员';
                break;
            case 3 :
                rankname = '普通成员';
                break;
            default : rankname = null
        }

        return rankname;
    }
}

module.exports = User;